import express from 'express';
import get_token from './atom/get-token';
import get_user_info from './atom/get-user-info';

(() => {
	const app = express();

	app.get('/get-user-info', async (req, res) => {
		res.header('Access-Control-Allow-Origin', '*');
		const data = req.query;
		const auth_code = data.code;
		try {
			const token_info = await get_token(auth_code);
			const user = await get_user_info(token_info.accessToken);
			res.send(user);
		} catch (err) {
			res.send(err);
		}
	});
	app.listen(9999);
})()
